package com.android.buildversion;

import android.os.Bundle;
import android.os.Build;
import android.widget.TextView;

import androidx.fragment.app.FragmentActivity;

/*
 * Main Activity class that loads {@link MainFragment}.
 */
public class MainActivity extends FragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // 获取 TextView
        TextView versionTextView = findViewById(R.id.tv_version);

        // 获取 Android 版本和 API 版本
        String androidVersion = Build.VERSION.RELEASE;
        int apiVersion = Build.VERSION.SDK_INT;

        // 设置 TextView 显示的文本
        String versionInfo = "Android Version: " + androidVersion + "\nAPI Level: " + apiVersion;
        versionTextView.setText(versionInfo);
    }
}